package com.vf.admin.miaodong.dao;

import com.vf.admin.common.db.BaseDao;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.AppCashWithdrawal;
import com.vf.admin.miaodong.entity.AppCashWithdrawalMoney;
import com.vf.admin.utils.StringEx;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import static com.vf.admin.utils.StringEx.isNull;

/**
 * 提现金额配置
 */
@Repository
public class AfterCashWithdrawalMoneyDao extends BaseDao<AppCashWithdrawalMoney> {

    /**
     * 查询列表
     */
    public List<AppCashWithdrawalMoney> list(Map<String,Object> map,SplitPageBean splitPageBean) {
        ArrayList<Object> paramList = new ArrayList<Object>();
        StringBuilder sbStr = new StringBuilder("select * from app_cashwithdrawal_money where 1=1  ");
        if(!isNull(map.get("leixing"))){
            sbStr.append(" and leixing=? ");
            paramList.add(map.get("leixing"));
        }
        sbStr.append(" order by money asc");
        String sql = sbStr.toString();
        return this.queryList(sql,paramList, AppCashWithdrawalMoney.class);
    }


    /**
     * 详情
     */
    public AppCashWithdrawalMoney get(Integer id) {
        if (StringEx.isNullOrLing(id)) {
            return null;
        }
        List<Object> paramList = new ArrayList<Object>();
        StringBuilder sbStr = new StringBuilder("select * from app_cashwithdrawal_money where 1=1");
        sbStr.append(" and id = ? ");
        paramList.add(id);
        String sql = sbStr.toString();
        return this.queryObj(sql, paramList, AppCashWithdrawalMoney.class);
    }

    /**
     * 添加/修改
     */
    public void save(AppCashWithdrawalMoney haoYou) {
        if (haoYou!=null && haoYou.getId() != null && haoYou.getId() > 0) {
            this.update(haoYou);
        } else {
            haoYou.setId(this.add(haoYou));
        }
    }

    /**
     * 删除
     */
    public void del(Integer id) {
        if (id==null || id <= 0) {
            return;
        }
        String sql = "delete  from app_cashwithdrawal_money where id = ?";
        ArrayList<Object> paramList = new ArrayList<Object>();
        paramList.add(id);
        this.del(sql, paramList);
    }


}
